import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# 指明服务驱动路径
seriver = Service(executable_path=r'E:\pc\me\.venv\chromedriver.exe')

# 打开浏览器
driver = webdriver.Chrome(service=seriver)
# 最大化
driver.maximize_window()

# 打开url
driver.get("https://quotes.toscrape.com/")
time.sleep(1)

# 找到登录入口
login_entry = driver.find_element(By.XPATH,'//a[@href="/login"]')
# 点击web元素
login_entry.click()
time.sleep(1)

username_input = driver.find_element(By.ID,'username')
username_input.send_keys("admin")
time.sleep(1)

password_input = driver.find_element(By.ID,'password')
password_input.send_keys("123456")
time.sleep(1)

submit_bin = driver.find_element(By.XPATH,'//input[@type="submit"]')
submit_bin.click()
time.sleep(1)

logout_entry = driver.find_element(By.CSS_SELECTOR, '.col-md-4>p>a')
logout_entry.click()

time.sleep(10)
# # 退出浏览器
driver.quit()
